<template>
  <div>
    <el-table
      :data="tableList"
      border
      style="margin: 10px 0"
      v-loading="loading"
    >
      <el-table-column
        prop="spread_id"
        label="平台ID"
        width="120"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="order_number"
        label="订单号"
        width="220"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="need_money"
        label="总金额"
        width="120"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="distribution_fee"
        label="配送费"
        width="120"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="receiver_name"
        label="收货人"
        width="120"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="receiver_mobile"
        label="收货人手机号"
        width="160"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="cost_price"
        label="成本价总金额"
        width="120"
        align="center"
      >
      </el-table-column>
      <el-table-column label="收货地址" width="160" align="center">
        <template slot-scope="scope">
          <div>
            {{
              scope.row.receiver_province +
              scope.row.receiver_city +
              scope.row.receiver_area
            }}
          </div>
        </template>
      </el-table-column>
      <el-table-column
        prop="receiver_address"
        label="详细地址"
        width="160"
        align="center"
      >
      </el-table-column>
      <el-table-column label="状态" min-width="120" align="center">
        <template slot-scope="scope">
          <div class="text">
            {{ behalfStatusText(scope.row.behalf_status) }}
          </div>
        </template>
      </el-table-column>
      <el-table-column
        prop="pay_time"
        label="支付时间"
        width="160"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="create_time"
        label="创建时间"
        width="160"
        align="center"
      >
      </el-table-column>
      <el-table-column
        label="操作"
        min-width="150"
        fixed="right"
        align="center"
      >
        <template slot-scope="scope">
          <el-button
            style="color: #67c23a"
            type="text"
            size="mini"
            @click="$emit('detail', scope.row)"
            >详情
          </el-button>
          <el-button
            style="color: #409eff"
            type="text"
            size="mini"
            v-if="scope.row.behalf_status == 50"
            @click="$emit('send', scope.row)"
            >发聚水潭
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      :page="page"
      :page_size="page_size"
      :total="total"
      @currentChange="currentChange"
      @sizeChange="sizeChange"
    ></pagination>
  </div>
</template>

<script>
export default {
  name: "myTable",
  data() {
    return {}
  },
  props: {
    tableList: {
      type: Array,
      default: () => [],
    },
    page: {
      type: Number,
      default: 1,
    },
    page_size: {
      type: Number,
      default: 10,
    },
    total: {
      type: Number,
      default: 0,
    },
    loading: {
      type: Boolean,
      default: true,
    },
  },
  computed: {
    behalfStatusText() {
      return (status) => {
        if (status == 50) {
          return "未发货"
        } else if (status == 60) {
          return "已发聚水潭"
        } else if (status == 100) {
          return "已发货"
        } else {
          return "已取消"
        }
      }
    },
  },
  methods: {
    currentChange(e) {
      this.$emit("currentChange", e)
    },
    sizeChange(e) {
      this.$emit("sizeChange", e)
    },
  },
}
</script>

<style lang="scss" scoped>
.text {
  color: $base-status-color;
}
</style>
